# run:
# python bjoern-test.py
           
from time import time
from time import sleep
import bjoern
           
def start():
    def return_hello(environ, start_response):
        sleep(1)
        start_response('200 OK', [('Content-Type','text/plain')])
        return ('Hello world.')
           
    def return_404(environ, start_response):
        start_response('404 Not Found', (('Content-Type','text/plain'), ))
        return "URL %s not found" % environ.get('PATH_INFO', 'UNKNOWN')
           
    dispatch = {
        '/': return_hello
    }
           
    def choose(environ, start_response):
        return dispatch.get(environ.get('PATH_INFO'), return_404)(environ, start_response)
    bjoern.run(choose, '0.0.0.0', 9090)
           
if __name__=='__main__':
    start()

